package com.baidu.controller;

import com.baidu.entity.PowerBean;
import com.baidu.entity.UserBean;
import com.baidu.service.UserService;
import net.sf.json.JSONArray;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class UserController {
    @Resource
    UserService us;
    @RequestMapping("/getPowerJson")
    public ModelAndView  getPowerJson(){
        ModelAndView mv=new ModelAndView("left");
        List<PowerBean> list=us.getPowerList();
        String json= JSONArray.fromObject(list).toString();
        mv.addObject("json",json);
        return mv;
    }
    @RequestMapping("/getUserList")
    public ModelAndView getUserList(){
        ModelAndView mv=new ModelAndView("user_list");
        List<UserBean> list=us.getUserList();
        mv.addObject("list",list);
        return mv;
    }
}
